clear
clc
% close all

pstyle = 'LM'; % 'LM' line and marker, 'LO' = Line only, 'NL' = no line, only markers

boot.soleLength = 33e-2;
binding.model = 'bulldog';
binding.nTubes = [2;2;1;1;1];

% binding.springs = [1,1,1e-6;
%     1,1,1e-4;
%     1,1,1e-1;
%     1,1,2e-1;
%     1.5,1,.5]*.0254*4;  %vector of spring lengths in series
% % data.binding.springs = [1,1]*.0254*4;
% binding.springType = {'blue','blue','red';
%     'gold','red','red';
%     'red','gold','red';
%     'gold','red','red';
%     'green','green','gold'}; %vector of spring types in series

binding.springs = [1,1;
    1,1;
    1,1;
    1,1;
    1,1]*.0254*4;  %vector of spring lengths in series
% data.binding.springs = [1,1]*.0254*4;
binding.springType = {'blue','blue';
    'red','red';
    'red','red';
    'gold','red';
    'gold','gold'}; %vector of spring types in series

binding.pivotPosition = 7;
binding.preload = 0.75*.0254;

hammerhead.preload = 0.25*.0254;

opts.a = 1;

plotInd = 0;




nCases = length(binding.springs(:,1));

% calc bulldog cases
for i = 1:nCases
    data(i).boot.soleLength = boot.soleLength;
    data(i).binding.model = binding.model;
    data(i).binding.nTubes = binding.nTubes(i);
    data(i).binding.springs = binding.springs(i,:);
    data(i).binding.springType = binding.springType(i,:);
    data(i).binding.pivotPosition = binding.pivotPosition;
    data(i).binding.preload = binding.preload;
    
    [data(i).rotation, data(i).Fh_torque, data(i).Fhs] = ...
        adaptiveLoadPath(data(i),opts,plotInd);
end

% calc hh cases

nHHpos = 5; 
for i = 1:nHHpos
    
%     plotInd = 1
    data(i+nCases).boot.soleLength = boot.soleLength;
    data(i+nCases).binding.model = 'hammerhead';
    data(i+nCases).binding.pivotPosition = i;
    data(i+nCases).binding.preload = hammerhead.preload;
    
    [data(i+nCases).rotation, data(i+nCases).Fh_torque,data(i + nCases).Fhs] = ...
        adaptiveLoadPath(data(i+nCases),opts,plotInd);
    
end

    
    

figure;
hold all
for i = 1:nCases
    ph(i) = plot(data(i).rotation,data(i).Fh_torque,pstyles(i,pstyle));
    lstring = [num2str(binding.nTubes(i)) ' tubes, ' ...
        num2str(binding.springs(i,1)/.0254) ' inch of ' binding.springType{i,1} ', ' ...
        num2str(binding.springs(i,2)/.0254) ' inch of ' binding.springType{i,2}];
     lvals{i} = lstring;
end

for i = 1:nHHpos
%     pause
    ph(i+nCases) = plot(data(i+nCases).rotation,data(i+nCases).Fh_torque,pstyles(i+nCases,pstyle));
    lstring = ['Hammerhead Position ' num2str(i)];
    lvals{i+nCases} = lstring;
end

xlabel('Heel rotation angle (deg)')
ylabel('Heel lift torque (N*m)')
legend(ph,lvals)
tstring = ['Sole Length = ' num2str(boot.soleLength)];
title(tstring)
grid on

% figure;
% hold all
% for i = 1:nCases
%     ph(i) = plot(data(i).rotation,data(i).Fhs);
%     lstring = [num2str(binding.nTubes(i)) ' tubes, ' ...
%         num2str(binding.springs(i,1)/.0254) ' inch of ' binding.springType{i,1} ', ' ...
%         num2str(binding.springs(i,2)/.0254) ' inch of ' binding.springType{i,2}];
%      lvals{i} = lstring;
% end
% 
% for i = 1:nHHpos
% %     pause
%     ph(i+nCases) = plot(data(i+nCases).rotation,data(i+nCases).Fhs);
%     lstring = ['Hammerhead Position ' num2str(i)];
%     lvals{i+nCases} = lstring;
% end
% 
% xlabel('Heel rotation angle (deg)')
% ylabel('Heel lift force (N)')
% legend(ph,lvals)
% tstring = ['Sole Length = ' num2str(boot.soleLength)];
% title(tstring)
% grid on